package com.site.service.impl.master;

import java.util.ArrayList;
import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Component;

import com.site.dao.master.ProvinceDao;
import com.site.dto.master.ProvinceBizBean;
import com.site.model.master.ProvinceInfo;
import com.site.service.master.ProvinceService;
import com.site.util.PropertyUtils;
import com.site.util.base.service.BaseServiceImpl;
import com.site.util.exception.ApplicationException;
import com.site.util.exception.SystemException;
import com.site.util.extremetable.QueryPage;

/**
 * 省市Service
 * 
 * @author lee
 * @date 2013年11月7日
 */
@Component
public class ProvinceServiceImpl extends BaseServiceImpl implements
		ProvinceService {

	private ProvinceDao provinceDao;

	@Resource
	public void setProvinceDao(ProvinceDao provinceDao) {
		this.provinceDao = provinceDao;
	}

	@Override
	public Object doExecute(Object obj, String command) throws SystemException,
			ApplicationException {
		// TODO Auto-generated method stub
		return null;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * com.site.service.impl.master.ProvinceDao#getProvinces(com.site.dto.master
	 * .ProvinceBizBean)
	 */
	@Override
	public List<ProvinceBizBean> getProvinces(ProvinceBizBean vo) {
		List<ProvinceInfo> provinceInfos = provinceDao.getProvinces(vo);
		if (provinceInfos != null && provinceInfos.size() > 0) {
			List<ProvinceBizBean> provinceBizBeans = new ArrayList<ProvinceBizBean>();
			for (ProvinceInfo provinceInfo : provinceInfos) {
				if (null != provinceInfo) {
					ProvinceBizBean provinceBizBean = new ProvinceBizBean();
					PropertyUtils.copyProperties(provinceBizBean, provinceInfo);
					provinceBizBeans.add(provinceBizBean);
				}
			}
			if (null != provinceBizBeans && provinceBizBeans.size() > 0) {
				return provinceBizBeans;
			}
		}
		return null;
	}

	@Override
	public List<ProvinceBizBean> getProvincesAndCitys(ProvinceBizBean vo,
			QueryPage queryPage) {
		List<ProvinceBizBean> provinceBizBeans = provinceDao.getProvincesAndCitys(vo, queryPage);
		if (provinceBizBeans != null && provinceBizBeans.size() > 0) {
			return provinceBizBeans;
		}
		return null;
	}

}
